#pragma once

#include<BWAPI.h>
#include<set>
#include<vector>

#include"ControlerBase.h"
#include"Controlers.h"
#include"MapInformation.h"

using namespace BWAPI;
using namespace std;

class OverlordControler : public ControlerBase
{
public:
	OverlordControler(Unit* overlord)
		:ControlerBase(overlord),
		_lastComputeFrame(-1)
	{
	}
	virtual void OnFrame()
	{
		if(IsDead())
		{
			return;
		}

		Position position = _unitToControl->getPosition();
		Broodwar->drawTextMap(position.x() , position.y() , "\x07 overlord");

		int frameNow = Broodwar->getFrameCount();
		if(frameNow - _lastComputeFrame > 317)
		{
			_lastComputeFrame = frameNow;
			/*bool nearOtherOverlord = false;
			for each(Unit* whichUnit in _unitToControl->getUnitsInRadius(200))
			{
				if(whichUnit->getPlayer() == Broodwar->self() && whichUnit->getType() == UnitTypes::Zerg_Overlord)
				{
					nearOtherOverlord = true;
				}
			}

			if(!nearOtherOverlord)
			{
				return;
			}
			
			vector<Position> positions;
			positions.push_back(MapInformation::GetChokepoint(0)->getCenter());
			positions.push_back(MapInformation::GetChokepoint(1)->getCenter());
			positions.push_back(MapInformation::GetBaseLocation(0)->getPosition());
			positions.push_back(MapInformation::GetBaseLocation(1)->getPosition());

			_unitToControl->move(positions[rand() % 4]);*/

			_unitToControl->move(MapInformation::GetChokepoint(1)->getCenter());
		}
	}
private:
	int _lastComputeFrame;
};